package com.ruoyi.project.lely.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.R;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.lely.bean.dto.LyStatusDTO;
import com.ruoyi.project.lely.bean.entity.LyGoods;
import com.ruoyi.project.lely.mapper.LyGoodsMapper;
import com.ruoyi.project.lely.service.LyGoodsService;
import org.springframework.stereotype.Service;

/**
 * @Desc: 商品实现类
 * @Author LuoYong
 * @Date 2022/1/17 18:14
 */
@DataSource(value = DataSourceType.SLAVE)
@Service
public class LyGoodsServiceImpl extends ServiceImpl<LyGoodsMapper, LyGoods> implements LyGoodsService {

    @Override
    public R changeStatus(LyStatusDTO dto) {
        boolean update = this.update(
                new LambdaUpdateWrapper<LyGoods>()
                        .eq(LyGoods::getId, dto.getId())
                        .set(LyGoods::getDeleted, dto.getStatus())
        );
        return update ? R.ok("操作成功"):R.fail();
    }
}
